package chixing.day20.work1;

import java.util.List;
import java.util.Map;

public class Test1 {
    public static void main(String[] args) {
        MemberService memberService = new MemberService();
        Member member1 = new Member(1, "张三", 0);
        Member member2 = new Member(2, "李四", 0);
        Member member3 = new Member(3, "王五", 0);
        Member member4 = new Member(4, "赵六", 0);
        Member member5 = new Member(5, "钱七", 0);
        memberService.addMember(member1);
        memberService.addMember(member2);
        memberService.addMember(member3);
        memberService.addMember(member4);
        memberService.addMember(member5);
        OrderRecord record1 = new OrderRecord(1, "普通房", 301);
        OrderRecord record2 = new OrderRecord(2, "高级房", 20);
        OrderRecord record3 = new OrderRecord(3, "套房", 101);
        OrderRecord record4 = new OrderRecord(1, "高级房", 20);
        OrderRecord record5 = new OrderRecord(4, "普通房", 50);
        OrderRecord record6 = new OrderRecord(5, "套房", 301);
        OrderRecord record7 = new OrderRecord(2, "套房", 10);
        memberService.recordStay(record1);
        memberService.recordStay(record2);
        memberService.recordStay(record3);
        memberService.recordStay(record4);
        memberService.recordStay(record5);
        memberService.recordStay(record6);
        memberService.recordStay(record7);

        System.out.println("前3名积分会员:");
        List<Member> topMembers = memberService.getTopNMembers(3);
        for (int i = 0; i < topMembers.size(); i++) {
            Member member = topMembers.get(i);
            System.out.println((i + 1) + ". " + member.getName() + " - " + member.getScore() + "积分");
        }
        System.out.println("\n各等级会员列表:");
        Map<String, List<Member>> groupedMembers = memberService.groupByLevel();
        for (Map.Entry<String, List<Member>> entry : groupedMembers.entrySet()) {
            String level = entry.getKey();
            List<Member> members = entry.getValue();
            System.out.println(level + "会员 (" + members.size() + "人):");
            for (Member member : members) {
                System.out.println("  " + member.getName() + " - " + member.getScore() + "积分");
            }
            System.out.println();
        }
    }
}
